package org.jsola.hr.helper;

import org.jsola.common.SafeKit;
import org.jsola.hr.dto.EmpSocBackRecordInfoAddDTO;
import org.jsola.hr.dto.EmpSocBackRecordInfoUpdateDTO;
import org.jsola.hr.entity.EmpSocBackRecordInfoDO;
import org.jsola.hr.query.EmpSocBackRecordInfoQuery;
import org.jsola.hr.service.IEmpSocBackRecordInfoService;
import org.jsola.hr.vo.EmpSocBackRecordInfoVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.math.BigDecimal;
import java.util.List;

import static org.jsola.hr.core.AbstractTest.SITE_ID;



/**
 * 社保回款信息
 *
 * @author zhr
 */
@Component
public class EmpSocBackRecordInfoTestHelper extends BaseTestHelper {
    
    @Autowired
    private IEmpSocBackRecordInfoService empSocBackRecordInfoService;

    /**
     * 生成add测试数据
     * @return EmpSocBackRecordInfoAddDTO
     */
    public EmpSocBackRecordInfoAddDTO getEmpSocBackRecordInfoAddDTO(){
        EmpSocBackRecordInfoAddDTO empSocBackRecordInfoAddDTO = new EmpSocBackRecordInfoAddDTO();
        empSocBackRecordInfoAddDTO.setEmpSocInfoId(getRandomValue("varchar",32));
        empSocBackRecordInfoAddDTO.setEmpId(getRandomValue("varchar",32));
        empSocBackRecordInfoAddDTO.setName(getRandomValue("varchar",50));
        empSocBackRecordInfoAddDTO.setPhone(getRandomValue("varchar",11));
        empSocBackRecordInfoAddDTO.setIdCard(getRandomValue("varchar",20));
        empSocBackRecordInfoAddDTO.setYear(getRandomValue("varchar",32));
        empSocBackRecordInfoAddDTO.setMonth(getRandomValue("varchar",32));
        empSocBackRecordInfoAddDTO.setCompanyId(getRandomValue("varchar",32));
        empSocBackRecordInfoAddDTO.setServiceCost(SafeKit.getBigDecimal(getRandomValue("decimal",11)));
        empSocBackRecordInfoAddDTO.setSocAmount(SafeKit.getBigDecimal(getRandomValue("decimal",11)));
        empSocBackRecordInfoAddDTO.setOverdueFine(SafeKit.getBigDecimal(getRandomValue("decimal",11)));
        empSocBackRecordInfoAddDTO.setTotalAmount(SafeKit.getBigDecimal(getRandomValue("decimal",11)));
        empSocBackRecordInfoAddDTO.setRealityAmount(SafeKit.getBigDecimal(getRandomValue("decimal",11)));
        empSocBackRecordInfoAddDTO.setAccountAmount(SafeKit.getBigDecimal(getRandomValue("decimal",11)));
        empSocBackRecordInfoAddDTO.setUncollectedAmount(SafeKit.getBigDecimal(getRandomValue("decimal",11)));
        empSocBackRecordInfoAddDTO.setStatus(SafeKit.getInteger(getRandomValue("tinyint",4)));
        empSocBackRecordInfoAddDTO.setRemark(getRandomValue("varchar",255));
        return empSocBackRecordInfoAddDTO;
    }


    /**
     * 生成update测试数据
     * @return EmpSocBackRecordInfoUpdateDTO
     */
    public EmpSocBackRecordInfoUpdateDTO getEmpSocBackRecordInfoUpdateDTO(EmpSocBackRecordInfoVO empSocBackRecordInfoVO){
        return empSocBackRecordInfoService.selectDOById(empSocBackRecordInfoVO.getId(), SITE_ID).to(EmpSocBackRecordInfoUpdateDTO.class);
    }

    /**
     * 生成查询数据
     * @return EmpSocBackRecordInfoQuery
     */
    public EmpSocBackRecordInfoQuery getEmpSocBackRecordInfoQuery() {
        EmpSocBackRecordInfoQuery empSocBackRecordInfoQuery = new EmpSocBackRecordInfoQuery();
        List<EmpSocBackRecordInfoDO> empSocBackRecordInfoDOList = empSocBackRecordInfoService.list(new EmpSocBackRecordInfoDO(),SITE_ID);
        if (!CollectionUtils.isEmpty(empSocBackRecordInfoDOList)) {
            EmpSocBackRecordInfoDO empSocBackRecordInfoDO = empSocBackRecordInfoDOList.get(0);
            empSocBackRecordInfoQuery = empSocBackRecordInfoDO.to(EmpSocBackRecordInfoQuery.class);
        }
        return empSocBackRecordInfoQuery;
    }

    /**
     * 保存示例
     * @return EmpSocBackRecordInfoVO
     */
    public EmpSocBackRecordInfoVO saveEmpSocBackRecordInfoExample(){
        EmpSocBackRecordInfoAddDTO addDTO = this.getEmpSocBackRecordInfoAddDTO();
        EmpSocBackRecordInfoVO empSocBackRecordInfoVO = empSocBackRecordInfoService.save(addDTO,buildTokenUser());
        return empSocBackRecordInfoVO;
    }


}

